package com.fifth.apartment.others;

import com.fifth.apartment.result.Result;
import com.fifth.apartment.service.GeoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.geo.GeoResults;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * TODO
 *
 * @author Dao
 * @since 2024/7/14
 */
@RestController
//@RequestMapping("/admin/geo")
//@Api(tags = "地址查询接口")
@Slf4j
public class GeoController {
    
    @Autowired
    private GeoService service;
    
    @ApiOperation( "添加景点数据")
    @GetMapping("addGeo")
    public Result addGeo(){
        Result result = service.addGeo();
        
        return result;
    }

    @ApiOperation( "添加景点经纬度数据")
    @GetMapping("addPoint")
    public Result addPoint(String longitude, String latitude){
        GeoResults result = service.addPoint( longitude, latitude);

        return new Result(true,"添加景点经纬度数据成功",result);
    }

    @ApiOperation("根据当前位置查询附近景点地理位置")
    @GetMapping("findBySite")
    public Result findBySite(String site){
        GeoResults result = service.findBySite(site);
        return new Result(true,"查询附近景点地理位置成功",result);
    }
}
